home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0574.ZIP / STRCPY.ASM < prev    next >
Assembly Source File  |  1986-11-21  |  598b  |  42 lines

  1. include compiler.inc
  2.     ttl    STRCPY, 1.04, 08-30-86, clr
  3.  
  4. ;string function - copies strg2 over strg1
  5. ;
  6. ;         - copies strg2 over strg1 at most n characters
  7. ;        NOTE:    If strg2 has more than cnt characters, the result
  8. ;                will NOT be null terminated!!
  9.  
  10.     dseg
  11.  
  12.     cseg
  13.  
  14.     procdef    strncpy, <<strg1, ptr>, <strg2, ptr>, <cnt,word>>
  15.     mov    cx,cnt
  16.     jmp    short start
  17.  
  18.     entrdef    strcpy
  19.     mov    cx,7fffh
  20.  
  21. start:
  22.     pushreg
  23.     pushds
  24.     jcxz    endit
  25.     ldptr    di,strg1
  26.     ldptr    si,strg2
  27.     cld
  28. lp:
  29.     lodsb
  30.     stosb
  31.     or    al,al
  32.     jz    endit
  33.     loop    lp
  34. endit:
  35.     clc
  36.     retptrm    strg1
  37.     pend    strncpy
  38.  
  39.     finish
  40.  
  41.     end
  42.